package cn.com.huzo.repository.master.impl;

import cn.com.huzo.model.entities.master.CustomerSizeLableEntity;
import huzofw.repository.impl.GenericRepositoryImpl;
import huzofw.repository.impl.MyBatisDaoUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import cn.com.huzo.repository.master.CustomerSizeLableRepository;

/**
 * 客户尺码标号数据访问对象。
 *
 * @author 吴旭
 */
@Repository("CustomerSizeLableRepository")
public class CustomerSizeLableRepositoryImpl extends GenericRepositoryImpl<CustomerSizeLableEntity, HashMap>
        implements CustomerSizeLableRepository {

    private final String namespace = "cn.com.huzo.repository.master.CustomerSizeLableRepository";

    /**
     * 构造函数,设置the entity to UserInCustomerGroupRepositoryImpl.class.
     */
    public CustomerSizeLableRepositoryImpl() {
        super(CustomerSizeLableEntity.class);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer fetchForCount(Map<String, Object> criterion) {
        return getSqlSession().selectOne(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchForCount"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<CustomerSizeLableEntity> fetchForPage(Map<String, Object> criterion) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchForPage"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer batchInsert(List<CustomerSizeLableEntity> itemList) {
        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "batchInsert"), itemList);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer importFromSize(Long customerId) {
        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "importFromSize"), customerId);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer copyFromOtherSizeLable(Long customerId, Long otherCustomerId) {
        Map<String, Object> criterion = new HashMap();
        criterion.put("CustomerId", customerId);
        criterion.put("OtherCustomerId", otherCustomerId);

        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "copyFromOtherSizeLable"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer batchUpdate(List<CustomerSizeLableEntity> itemList) {
        return getSqlSession().update(MyBatisDaoUtils.getMapperQueryId(
                namespace, "batchUpdate"), itemList);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer delete(HashMap key) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "delete"), key);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer batchDelete(List<CustomerSizeLableEntity> itemList) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "batchDelete"), itemList);
    }
}
